using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LAFDC.DataAccess;

namespace LAFDC.Web.UI {
    public partial class EditeurRapport : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e){
            lblERROR.Visible = false;
        }

        protected void btExecuteCommand_Click(object sender, EventArgs e) {
            try {
                ConnectionManager cm = new ConnectionManager();
                SqlDataSource ds = new SqlDataSource(cm.GetConnectionString(), txtSQLCommand.Text);

                dataGrid.DataSource = ds;
                dataGrid.DataBind();
                if (!dataGrid.Visible) {
                    dataGrid.Visible = true;
                }
            }
            catch (Exception ex){
                dataGrid.Visible = false;
                lblERROR.Visible = true;
                lblERROR.Text = "<blockquote><b>Error Message: </b><br/><blockquote>" + ex.Message + "</blockquote><br />";
                lblERROR.Text += "<b>Source: </b><br/><blockquote>" + ex.Source + "</blockquote><br />";
                lblERROR.Text += "<b>Stack trace: </b><br/><blockquote>" + ex.StackTrace + "</blockquote><br/></blockquote>";
            }
        }
    }
}
